home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / portable / wsetscrr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  2.0 KB  |  70 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #undef    wsetscrreg
  4.  
  5. #ifdef PDCDEBUG
  6. char *rcsid_wsetscrr = "$Header: C:\CURSES\portable\RCS\wsetscrr.c 2.1 1993/06/18 20:21:54 MH Rel MH $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   wsetscrreg()    - set scrolling region
  15.  
  16.   X/Open Description:    setscrreg(), wsetscrreg()
  17.      These functions allow the suer to set a software scrolling region
  18.      in a window.  The parameters 'top' and 'bot' are the line numbers
  19.      of the top and bottom margin of the scrolling region.  (Line 0 is
  20.      the top line of the window.)  If this option and scrollok() are
  21.      enabled, an attempt to move off the bottom margin will cause all
  22.      lines in the scrolling region to scroll up one line.  Only the
  23.      text of the window is scrolled.
  24.  
  25.   PDCurses Description:
  26.      PDCurses implements the standard OK and ERR return values.
  27.  
  28.      FYI: setscrreg() is also defined as a macro.
  29.  
  30.   X/Open Return Value:
  31.      No return values are defined for these functions.
  32.  
  33.   PDCurses Errors:
  34.      It is an error to pass a NULL WINDOW pointer.
  35.      The top and bottom coordinates must be inside the passed window
  36.      and must bound the window's cursor position.  e.g.  The cursor
  37.      cannot be above or below the top or bottom margins.
  38.  
  39.   Portability:
  40.      PDCurses    int wsetscrreg( WINDOW* win, int top, int bottom );
  41.      X/Open Dec '88    int wsetscrreg( WINDOW* win, int top, int bottom );
  42.      SysV Curses    int wsetscrreg( WINDOW* win, int top, int bottom );
  43.      BSD Curses    int wsetscrreg( WINDOW* win, int top, int bottom );
  44.  
  45. **man-end**********************************************************************/
  46.  
  47. int    wsetscrreg(WINDOW *win, int top, int bottom)
  48. {
  49. #ifdef PDCDEBUG
  50.     if (trace_on) PDC_debug("wsetscrreg() - called: top %d bottom %d\n",top,bottom);
  51. #endif
  52.  
  53.     if (win == (WINDOW *)NULL)
  54.         return (ERR);
  55.  
  56.     if ((0 <= top) &&
  57.         (top <= win->_cury) &&
  58.         (win->_cury <= bottom) &&
  59.         (bottom < win->_maxy))
  60.     {
  61.         win->_tmarg = top;
  62.         win->_bmarg = bottom;
  63.         return (OK);
  64.     }
  65.     else
  66.     {
  67.         return (ERR);
  68.     }
  69. }
  70.